using System.Data;
using Castle.ActiveRecord;
using NHibernate;

namespace CastleSample.DataAccess.AR
{
    public abstract class ARDataServiceBase : ActiveRecordBase
    {
        private ISessionFactory m_SessionFactory;
        public ARDataServiceBase() {}

        public ARDataServiceBase(ISessionFactory sessionFactory)
        {
            m_SessionFactory = sessionFactory;
        }

        public virtual ISession GetHibernateSession()
        {
            return m_SessionFactory.OpenSession();
        }

        public IDbConnection GetDbConnection()
        {
            return m_SessionFactory.OpenSession().Connection;
        }
    }
}